Einhugur Xml Plugin for Xojo

Node.SelectNode Method

The SelectNode function compiles the XPath expression and then executes it with the node as a context node, and returns the result as a single XPathNode, the node that makes the first hit. The function can optionally take in XPath variables.

SelectNode(
   query as String,
   variables as EinhugurXml.XPathVariableSet) as EinhugurXml.XPathNode

Parameters

query
The expression query.
variables
This is optional parameter with default value nil.

This parameter takes in XPathVariableSet to use in the query.

Returns

EinhugurXml.XPathNode
XPathNode which can carry either Node or Attribute depending on the Query.

Remarks

Note that XPathNode can carry either Node or Attribute.

This function can throw EinhugurXPathException.

Example:

var xnode as EinhugurXml.XPathNode = doc.SelectNode("//Tool[contains(Description, 'build system')]")

if xnode <> nil then
    MessageBox xnode.Node.ToString()
end if



While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you’re doing many similar queries, consider compiling them into query objects. Once you get a compiled query object, you can pass it to select functions instead of an expression string.

See Also

Node Class